import React, { memo } from "react";
import { TabBar } from "antd-mobile";
import {
  AppOutline,
  MessageOutline,
  UnorderedListOutline,
  UserOutline,
} from "antd-mobile-icons";
import { useLocation, useNavigate } from "react-router-dom";
const MyTarbar = memo(() => {
  let location = useLocation();
  let navigate = useNavigate();
  const tabs = [
    {
      key: "/home",
      title: "首页",
      icon: <AppOutline />,
    },
    {
      key: "/about",
      title: "待办",
      icon: <UnorderedListOutline />,
    },
    {
      key: "/message",
      title: "消息",
      icon: <MessageOutline />,
    },
    {
      key: "/my",
      title: "我的",
      icon: <UserOutline />,
    },
  ];
  return (
    <div>
      <TabBar activeKey={location.pathname} onChange={(v) => navigate(v)}>
        {tabs.map((item) => (
          <TabBar.Item key={item.key} icon={item.icon} title={item.title} />
        ))}
      </TabBar>
    </div>
  );
});

export default MyTarbar;
